<template>
  <div class="snapshot">
    <div class="snap-header c-shadow">
      <h4>{{entname}}<span @click="goback" class="fr">返回</span></h4>
      <div class="clearFix">
        <p class="fl">关键词：{{keyword}}</p>
        <a :href="showImgSrc" target="_blank" class="fr download">下载</a>
        </div>
      <!-- <div class="snap-carousel">
        <span class="prev" @click="prev">&lt;</span>
        <div class="carousel-wrap">
          <ul class="clearFix carousel-move-dom">
            <li v-for="(item,index) in snapData" :key="item.num" @click="itemSelect(index+1,$event)">
              <img :src="item.src" alt="">
            </li>
          </ul>
        </div>
        <span class="next" @click="next">&gt;</span>
      </div> -->
    </div>
    <div class="snap-content s-shadow">
      <img :src="showImgSrc" alt="">
      <!-- <div class="page-num">{{currentImgNum}}/{{snapData.length}}</div>
      <p>所在页面：<a href="http://www.tjbsrc.com/">http://www.tjbsrc.com/</a></p> -->
    </div>
  </div>
</template>
<script>
// import { entdetail as api } from '../../api'
export default {
  data() {
    return {
      entname: '',
      picName: '',
      keyword: '',
      snapData: [
        {
          num: 1,
          src: '../../../static/images/snap1.jpg'
        },
        {
          num: 2,
          src: '../../../static/images/snap1.jpg'
        },
        {
          num: 3,
          src: '../../../static/images/snap1.jpg'
        },
        {
          num: 4,
          src: '../../../static/images/snap1.jpg'
        },
        {
          num: 5,
          src: '../../../static/images/snap1.jpg'
        },
        {
          num: 6,
          src: '../../../static/images/snap1.jpg'
        },
        {
          num: 7,
          src: '../../../static/images/warn.png'
        }
      ],
      showImgSrc: '',
      currentImgNum: 1,
      // 轮播相关参数
      step: 0,
      moveStride: 200 + 20
    }
  },
  methods: {
    goback() {
      this.$router.go(-1)
    },
    // 轮播上一张按钮方法
    prev() {
      // let snapLength = this.snapData.length
      let carouselWrapDom = document.querySelector('.carousel-move-dom')
      if (this.step <= 0) {
        return false
      }
      this.step--
      carouselWrapDom.style.transform = `translate3d(${-this.step *
        this.moveStride}px,0,0)`
    },
    // 轮播下一张按钮方法
    next() {
      let snapLength = this.snapData.length
      let carouselWrapDom = document.querySelector('.carousel-move-dom')
      if (snapLength < 6 || this.step >= snapLength - 5) {
        return false
      }
      this.step++
      carouselWrapDom.style.transform = `translate3d(${-this.step *
        this.moveStride}px,0,0)`
    },
    // 轮播项点击方法
    itemSelect(index, e) {
      const liDoms = document.querySelectorAll('.carousel-move-dom li')
      Array.from(liDoms).map(li => li.classList.remove('select'))
      let currentDom = e ? e.target : liDoms[index - 1]
      currentDom.classList.add('select')
      this.showImgSrc = currentDom.childNodes[0].src
      this.currentImgNum = index
      // console.log(e.target.childNodes[0].src)
    }
  },
  mounted() {
    this.entname = this.$route.query.entname
    this.picName = this.$route.query.picName
    this.keyword = this.$route.query.keywords
    // this.itemSelect(1)
    this.showImgSrc =
      // window.api_host + '/icpUrlStatistic/showPngByName?pngName=' + this.picName
      window.api_fhzCount + '/importEntInfo/showPngByName?pngName=' + this.picName
  }
}
</script>
<style lang="scss" scoped>
.snap-header {
  padding: 28px 30px;
  margin: 20px 0 18px 0;
  h4 {
    font-size: 16px;
    margin-bottom: 30px;
    span {
      background: #1769e5;
      color: #fff;
      font-size: 14px;
      padding: 1px 15px;
      border-radius: 5px;
      cursor: pointer;
    }
  }
  .download {
    background: #1769e5;
    color: #fff;
    font-size: 14px;
    padding: 1px 15px;
    border-radius: 5px;
    cursor: pointer;
  }
  .snap-carousel {
    display: flex;
    align-items: center;
    .prev,
    .next {
      color: #4ca4f6;
      border: 1px solid #a0c7fd;
      border-radius: 50%;
      width: 30px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      cursor: pointer;
    }
    .carousel-wrap {
      flex: 1;
      height: 152px;
      margin: 0 72px;
      overflow: hidden;
      ul {
        width: 10000px;
        transition: transform 0.5s ease-in-out;
        li {
          border: 1px solid #3598f5;
          float: left;
          position: relative;
          width: 200px;
          img {
            width: 200px;
            height: 150px;
            vertical-align: top;
          }
          &::before {
            content: '';
            display: block;
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            background: rgba(255, 255, 255, 0.8);
          }
          &.select {
            &::before {
              display: none;
            }
          }
        }
        li + li {
          margin-left: 20px;
        }
      }
    }
  }
}
.snap-content {
  padding: 38px 0 30px;
  img {
    display: block;
    width: 950px;
    height: 630px;
    margin: 0 auto 30px;
  }
  .page-num {
    box-sizing: border-box;
    width: 60px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    font-size: 16px;
    color: #3598f5;
    background: #f2fbff;
    margin: 0 auto 20px;
    border: 1px solid #3598f5;
    border-radius: 30px;
  }
  p {
    text-align: center;
    a {
      color: #0b6dda;
    }
  }
}
</style>



// WEBPACK FOOTER //
// src/view/clib/snapshot.vue